package com.cn.wanxi.util.utils;

import com.cn.wanxi.util.model.CommunalTitle;
import com.cn.wanxi.util.model.ContactModel;
import com.cn.wanxi.util.model.NavModel;

import java.util.ArrayList;
import java.util.List;

public class NavUtile {
    FileUtile fileUtile =new FileUtile();
    public List<NavModel> readNav(){
        List<NavModel> navModelList =new ArrayList<>();
        String navtext = fileUtile.readFileToString("NavFile.txt");
        String[] navs = navtext.split(";");
        for (int i=0;i<navs.length;i++){
            String item = navs[i];
            String[] info =item.split(",");
            NavModel navModel =new NavModel(info[0].trim(),info[1].trim());
            navModelList.add(navModel);
        }
        return navModelList;
    }

    public List<ContactModel> readContac(){
        List<ContactModel> contactList =new ArrayList<>();
        String contact = fileUtile.readFileToString("ContactFile.txt");
        String[] contacts = contact.split(";");
        for (int i=0;i<contacts.length;i++){
            String item = contacts[i];
            String[] info =item.split(",");
            ContactModel contactModel = new ContactModel(info[0].trim(),info[1].trim());
            contactList.add(contactModel);
        }
        return contactList;
    }


    public List<CommunalTitle> readCommunalTitle() {
        List<CommunalTitle> communalTitleList = new ArrayList<>();
        String communal = fileUtile.readFileToString("SchoolContacFile.txt");
        String[] communals = communal.split(";");
        for (int i = 0; i < communals.length; i++) {
            String item = communals[i];
            String[] info = item.split(",");
            CommunalTitle communalTitle =new CommunalTitle(info[0].trim(),info[1].trim());
            communalTitleList.add(communalTitle);
        }
        return communalTitleList;
    }
}
